#ifndef H_I_PROTOCOL_SOCKET_IMPL_H
#define H_I_PROTOCOL_SOCKET_IMPL_H

#include "../typedefine.h"
#include "../promise.h"
#include "EProtocolErrorCode.h"

namespace QWER
{
	struct SProtocolSocketRecvRet
	{
	public:
		SProtocolSocketRecvRet(EProtocolErrorCode eErrorCode, std::unique_ptr<std::vector<UINT8>>&& poRecvData)
		{
			m_eErrorCode = eErrorCode;
			m_poRecvData = std::move(poRecvData);
		}
#ifndef _USING_CLI
		SProtocolSocketRecvRet()
		{
		}
#endif
	public:
		EProtocolErrorCode m_eErrorCode = EProtocolErrorCode::Error;
		std::unique_ptr<std::vector<UINT8>> m_poRecvData;
	};

	QDLL_EXPORT QINTERFACE IProtocolSocketImpl
	{
	public:
#ifndef _USING_CLI
		virtual ~IProtocolSocketImpl(){}
#endif
		virtual CPromise<EProtocolErrorCode>& Send(const std::shared_ptr<std::vector<UINT8>>& rsBuffer) = 0;
		virtual CPromise<SProtocolSocketRecvRet>& Recv(std::unique_ptr<std::vector<UINT8>>&& rsBuffer) = 0;
		virtual void Close() = 0;
		virtual UINT32 GetLocalIp() const = 0;
		virtual UINT16 GetLocalPort() const = 0;
		virtual UINT32 GetPeerIp() const = 0;
		virtual UINT16 GetPeerPort() const = 0;
	};
}

#endif
